主题
截图返回字节流 - GetScreenData
函数简介
获取指定区域的图像数据,以BGRA格式二进制数据返回,每个像素占用4字节。此接口线程不安全,不推荐使用。
接口名称
GetScreenDataDLL调用
int GetScreenData(long ola, int x1, int y1, int x2, int y2, long* data, int* size, int* stride);参数说明
| 参数名 | 类型 | 说明 |
|---|---|---|
| ola | 长整数型 | OLAPlug对象的指针,由 CreateCOLAPlugInterFace 接口生成。 |
| x1 | 整数型 | 区域的左上X坐标 |
| y1 | 整数型 | 区域的左上Y坐标 |
| x2 | 整数型 | 区域的右下X坐标 |
| y2 | 整数型 | 区域的右下Y坐标 |
| data | 长整数型指针 | 返回图片数据的指针地址 |
| size | 整数型指针 | 返回图片数据的总长度(字节数) |
| stride | 整数型指针 | 返回图片每行数据的字节数 |
示例
SDK 调用
cpp
#include "OLAPlugServer.h"
OLAPlugServer ola;
int ret = ola.GetScreenData(0, 0, 0, 0, "value", "value", "value");csharp
using OLAPlug;
var ola = new OLAPlugServer();
int ret = ola.GetScreenData(0, 0, 0, 0, "value", "value", "value");python
from OLAPlugServer import OLAPlugServer
ola = OLAPlugServer()
ret = ola.GetScreenData(0, 0, 0, 0, "value", "value", "value")java
import com.olaplug.OLAPlugServer;
OLAPlugServer ola = new OLAPlugServer();
int ret = ola.GetScreenData(0, 0, 0, 0, "value", "value", "value");cpp
var ola = com("OlaPlug.OlaSoft")
var ret = ola.GetScreenData(0, 0, 0, 0, "value", "value", "value")vbscript
Set ola = CreateObject("OlaPlug.OlaSoft")
ret = ola.GetScreenData(0, 0, 0, 0, "value", "value", "value")text
.局部变量 ola, OLAPlug
ola.创建 ()
ret = ola.GetScreenData(0, 0, 0, 0, “value”, “value”, “value”)aardio
import OLAPlugServer;
var ola = OLAPlugServer();
var ret = ola.GetScreenData(0, 0, 0, 0, "value", "value", "value");text
变量 ola <类型 = OLAPlugServer>
ola = 新建 OLAPlugServer
整数 ret = ola.GetScreenData(0, 0, 0, 0, "value", "value", "value")cpp
#include "OLAPlugServer.h"
OLAPlugServer ola;
int32_t ret = ola.GetScreenData(0, 0, 0, 0, "value", "value", "value");原生 DLL 调用
cpp
long instance = CreateCOLAPlugInterFace();
GetScreenData(instance, 0, 0, 0, 0, 0, 0, 0);csharp
using System.Runtime.InteropServices;
using System.Text;
[DllImport("OLAPlug_x64.dll", CallingConvention = CallingConvention.StdCall)]
static extern long CreateCOLAPlugInterFace();
[DllImport("OLAPlug_x64.dll", CallingConvention = CallingConvention.StdCall)]
static extern int GetScreenData(long ola, int x1, int y1, int x2, int y2, long data, int size, int stride);
long instance = CreateCOLAPlugInterFace();
GetScreenData(instance, 0, 0, 0, 0, 0, 0, 0);python
from ctypes import CDLL, c_int, c_int64, create_string_buffer
ola = CDLL("OLAPlug_x64.dll")
ola.CreateCOLAPlugInterFace.restype = c_int64
instance = ola.CreateCOLAPlugInterFace()
ola.GetScreenData(instance, 0, 0, 0, 0, 0, 0, 0)返回值
整数型:1 成功,0 失败。
注意事项
- 此接口线程不安全,建议使用 GetScreenDataPtr + GetImageData + FreeImagePtr 替代。
- 图像宽度 = stride / 4,图像高度 = size / stride。
- 数据指针在下次调用前有效,需及时拷贝数据。
- x1, y1, x2, y2 全传0时获取窗口整个客户区。
